-- 使用方法：复制到模组环境 self.inst.a_buffmult = 2 为受到buff时长倍率
local Debuffable = require "components/debuffable"

local _AddDebuff = Debuffable.AddDebuff
function Debuffable:AddDebuff(name, prefab, data, buffer, ...)
    local ent = _AddDebuff(self, name, prefab, data, buffer, ...)

    local mult = self.inst.a_buffmult
    if mult and ent and ent.components.debuff then
        local timer = ent.components.timer
        if timer then   --timer组件计时的buff
            if timer:TimerExists("buffover") then
                local time = timer:GetTimeLeft("buffover")
                timer:StopTimer("buffover")
                timer:StartTimer("buffover", time * mult)
            elseif timer:TimerExists("regenover") then
                local time = timer:GetTimeLeft("regenover")
                timer:StopTimer("regenover")
                timer:StartTimer("regenover", time * mult)
            end
        elseif ent.task then --task计时，如女武神战歌buff
            local time = GetTaskRemaining(ent.task)
            if time > 0 then
                ent.task.period = time * mult
            end
        end
    end

    return ent
end